﻿@{
    Layout = null;
}
<!DOCTYPE html>
<html>
<head>
    <title>Index</title>
    <link href="../../Scripts/PageCreater/Css/Style.css" rel="stylesheet" type="text/css" />
    <script src="../../Scripts/PageCreater/Scripts/jquery-1.5.1.min.js" type="text/javascript"></script>
    <script src="../../Scripts/zTree/js/jquery.ztree.core-3.5.js" type="text/javascript"></script>
    <script src="../../Scripts/zTree/js/jquery.ztree.exedit-3.5.js" type="text/javascript"></script>
    <script src="../../Scripts/zTree/js/jquery.ztree.excheck-3.5.js" type="text/javascript"></script>
    <link href="../../Scripts/zTree/css/zTreeStyle/zTreeStyle.css" rel="stylesheet" type="text/css" />
    <script language="javascript" type="text/javascript">
        var zTree;
        var demoIframe;
        var setting = {
            view: {
                dblClickExpand: false,
                showLine: true,
                selectedMulti: false
            },
            data: {
                simpleData: {
                    enable: true,
                    idKey: "id",
                    pIdKey: "pId",
                    rootPId: ""
                }
            },
            callback: {
                beforeClick: function (treeId, treeNode) {
                    var zTree = $.fn.zTree.getZTreeObj("tree");
                    if (treeNode.isParent) {
                        zTree.expandNode(treeNode);
                        return true;
                    } else {
                        demoIframe.attr("src", treeNode.file);
                        return true;
                    }
                }
            }
        };



        function Show() {
        }
         var zNodes = [
             @Html.Raw(@TempData["ZTree"].ToString())
		];

        $(document).ready(function () {
            var t = $("#tree");
            t = $.fn.zTree.init(t, setting, zNodes);
            demoIframe = $("#testIframe");
            demoIframe.bind("load", loadReady);
            var zTree = $.fn.zTree.getZTreeObj("tree");
            zTree.selectNode(zTree.getNodeByParam("id", 1));

        });
        function showIconForTree(treeId, treeNode) {
            return !treeNode.isParent;
        };
        function loadReady() {
            var bodyH = demoIframe.contents().find("body").get(0).scrollHeight,
		    htmlH = demoIframe.contents().find("html").get(0).scrollHeight,
		    maxH = Math.max(bodyH, htmlH), minH = Math.min(bodyH, htmlH),
		    h = demoIframe.height() >= maxH ? minH : maxH;
            if (h < 530) h = 530;
            demoIframe.height(h);
        }

        function editNode(text) {
			var zTree = $.fn.zTree.getZTreeObj("tree");
			nodes = zTree.getSelectedNodes(),
			treeNode = nodes[0];
            treeNode.name = text;
            zTree.updateNode(treeNode);
		};
        function deleteNode(){
            var zTree = $.fn.zTree.getZTreeObj("tree");
			nodes = zTree.getSelectedNodes(),
			treeNode = nodes[0];
            var callbackFlag = $("#callbackTrigger").attr("checked");
			zTree.removeNode(treeNode, callbackFlag);
        }
        function AddNode(pid,name){
         var zTree = $.fn.zTree.getZTreeObj("tree");
         var  node = zTree.getNodeByParam("id",pid,null);
         var jsonName = eval(name);
          node=zTree.addNodes(node,jsonName[0]);
        }
    </script>
</head>
<body>
    <table border="0" height="400px" align="left" style="font-size: 13px; margin-top: 9px;">
        <tr>
            <td width="260px" align="left" valign="top" style="border-right: #999999 1px dashed">
                <br />
                <div>
                    <a href="/Question/Create?CoureseID=@TempData["ID"]" target="testIframe">添加新题目</a></div>
                <br />
                <ul id="tree" class="ztree" style="width: 260px; overflow: auto;">
                </ul>
            </td>
            <td width="100%" align="left" valign="top">
                <iframe id="testIframe" name="testIframe" frameborder="0" scrolling="auto" width="100%"
                    height="600px"></iframe>
            </td>
        </tr>
    </table>
</body>
</html>
